package org.lyl.vhr.service;

import org.lyl.vhr.mapper.MenuMapper;
import org.lyl.vhr.model.Hr;
import org.lyl.vhr.model.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lylbell
 * @date 2020-08-06 09:47
 */
@Service
public class MenuService {

    @Autowired
    private MenuMapper menuMapper;

    //通过获取springSecurity中的登录信息--->来获取id,因为前端数据不可信，所以不要用前端传过来的数据信息。
    //通过id获取menu。
    public List<Menu> findMenuByHrId() {
        return menuMapper.selectMenuByHrId(((Hr) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
    }
}
